#ifndef __CALLBACK_H__
#define __CALLBACK_H__

#include <windows.h>

#include "widget.h"

struct callback_node
{
    // handler to the widgets window
    HWND hwnd;
    // pointer to the widget
    widget_t *widget;
    // pointer to the next callback_node in the list
    struct callback_node *next;
};

/*! Allocate memory for the callback hash table
 *
 * \param size of hash table, more widget = larger table
 */
void callback_alloc(size_t);

/*! Bind a window handler to widget information
 *
 * \param hwnd: handler to the window to bind
 * \note A hwnd can only be bind ones.
 */
void callback_bind(HWND,widget_t*);

/*! Find callback node for a given window handler
 *
 * \param hwnd: handler to the window
 * \return pointer to the callback function, NULL if not found
 */ 
struct callback_node *callback_find_node(HWND);

/*! Find widget for a given window handler
 *
 * \param hwnd: handler to the window
 * \retrun pointer to found widget, NULL if not found
 */
widget_t *callback_find_widget(HWND);

/* Free memmory for all widget and remove them from the hash table.
 */
void callback_free();

#endif // __CALLBACK_H__

